package com.mindframe.advreader;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ADVAdapter extends ArrayAdapter<ADV>{
	ArrayList<ADV> advs;
	Context context;
	
	public ADVAdapter(Context context, int textViewResourceId, ArrayList<ADV> advs) {
		super(context, textViewResourceId);
		
		this.advs=advs;
		this.context = context;
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		if(convertView != null){ 
			LayoutInflater inflater = (LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.fila, null);
		}
		ADV adv = advs.get(position);
		if(adv != null){
			TextView tv1 = (TextView)convertView.findViewById(R.id.FilaTexto1);
			TextView tv2 = (TextView)convertView.findViewById(R.id.FilaTexto2);
			
			if(tv1 != null){
				tv1.setText(adv.getTitulo());
			}
			if(tv2 != null){
				tv2.setText(adv.getDescripcion());
			}
		}
		return convertView;
	}
}
